/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dataentry;

import java.util.Iterator;
import java.util.Stack;

/**
 *
 * @author i.capurro
 */
public class MultipleQ extends Question {
    
    private Stack answers = null;
    private int length;
    
    public MultipleQ(String name, int lenght) {
        super(name);
        this.length = lenght;
        answers = new Stack();
    }

    public void setLenght(int lenght) {
        this.length = lenght;
    }
    
    @Override
    public Stack getAnswers() {
        return answers;
    }
    
    @Override
    public void pushAnswer (String val) {
        if (answers.size() < length) {
            answers.push(val);
        }
    }
    
    @Override
    public void popAnswer () {
        answers.pop();
    }
    
    @Override
    public String getAnswer() {
        if (!answers.empty()) {
            return (String) answers.get(0);
        }
        return null;
    }

    @Override
    public int getLength() {
        return length;
    }
    
    @Override
    public void emptyAnswers() {
        answers.clear();
    }
    
    @Override
    public boolean hasValue(String val) {
        return answers.contains(val);
    }
    
}
